package cn.tedu._06interceptor.config;

import cn.tedu._06interceptor.interceptors.MyInterceptor1;
import cn.tedu._06interceptor.interceptors.MyInterceptor2;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    public void addInterceptors(InterceptorRegistry registry) {
        //第一种：拦截所有请求
        registry.addInterceptor(new MyInterceptor1());
        registry.addInterceptor(new MyInterceptor2());
        //第二种：拦截指定请求（一个或多个）比如：拦截注册和登录请求
        /*registry.addInterceptor(new MyInterceptor1())
                .addPathPatterns("/v1/users/login","/v1/users/reg");*/
        //第三种：拦截指定模块的请求

        //第四种：拦截指定模块中除指定模块意外的所有请求
       /* registry.addInterceptor(new MyInterceptor1())
                .addPathPatterns("/v1/users/**")
                .excludePathPatterns("/v1/users/login");*/
    }

}
